package com.cg.controller;
import com.cg.Dto.*;
import com.cg.entity.Farm;
import com.cg.result.R;
import com.cg.service.FarmService;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.Data;
import org.springframework.web.bind.annotation.*;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lhy
 * @since 2024-12-26
 */
@RestController
@RequestMapping("/farm")
public class FarmController {
    @Resource
   private FarmService farmService;
@GetMapping("/searchList")
@Schema(description = "牧场查询接口")
    public R<Farm> search(@ModelAttribute @Valid SearchFarmDto searchFarmDto)
{
    return farmService.searchs(searchFarmDto);
}
@PostMapping("/insertFarm")
@Schema(description = "新增牧场接口")
    public R<?> insert(@RequestBody @Valid InsertFarmDto insertFarmDto){
    return  farmService.inserts(insertFarmDto);
}
@PutMapping("/updateFarm")
@Schema(description ="修改牧场接口")
public R<?> uodate(@RequestBody @Valid UpdateFarmDto updateFarmDto)
{
    return farmService.updateFarm(updateFarmDto);
}
@PutMapping("/updateStatus")
@Schema(description = "修改牧场状态接口")
public R<?> updateStatus(@RequestBody @Valid UpdateFramStatusDto updateFramStatusDto)
{
 return  farmService.updateStatus(updateFramStatusDto);
}
@GetMapping("/searchDetail")
@Schema(description = "查询牧场详情接口")
public R<?> getdetail(@ModelAttribute @Valid GetInsertFramDto getInsertFramDto)
{
      return  farmService.searchdetail(getInsertFramDto);
}
@GetMapping("/getFarmByStatus")
@Schema(description = "查询已启用牧场接口")
    public R<Farm>getFarnByStatus()
{
    return farmService.getFarnByStatus();
}
}
